package com.liciecruzadinha.app;

import android.os.Environment;
import android.util.Log;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;

/**
 * Created by chico on 28/05/14.
 */
public class FileUtil {

    private String nomeArquivo = "historico.txt";

    public void salvarExternalStorage(String texto, File base) {
        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {

            try {
                try {
                    File f = new File(Environment.getExternalStorageDirectory(),nomeArquivo);
                    FileOutputStream out = new FileOutputStream(f);
                    out.write(texto.getBytes());
                    out.write("\n".getBytes());
                    out.flush();
                    out.close();
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                } finally {
                }
            } catch (Exception e) {
                System.out.println(e.toString());
            }
        }
    }
}
